#include "ScriptComponent.h"

ScriptComponent::ScriptComponent() : Component() { init(); }
ScriptComponent::ScriptComponent(ComponentContainer* c, const std::string& name) : Component(c, name)
{
	init();
}


ScriptComponent::~ScriptComponent()
{
}

typedef void(*FrameAction)(::Object*,float);

void ScriptComponent::init()
{
	mGo = dynamic_cast<GameObject*>(mContainer);

	//mActions.addProperty<FrameAction>("update", 0);

//	mActions.addProperty<std::string>("update", "");
//	mGo->addProperty<Object>("actions", mActions);

	mGo->addProperty<Object>("actions", mActions);

	Ogre::Root::getSingleton().addFrameListener(this);
}

bool ScriptComponent::frameStarted(const FrameEvent& evt)
{

/*
	if(mActions.hasProperty("update"))
		{
		std::string script = mActions.getProperty<std::string>("update");
		ScriptObject so;
		so.Code = script;
		so.Type = "lua";
		ScriptManager::getSingletonPtr()->execute(&so);
		}
*/
	return true;
}
